.PHONY: backend ps up down logs

DC=docker-compose -f docker-compose.prod.yml
CERT=~/gurren/traefik.acme.json
DEV_CERT=./traefik/acme.json

build:
	docker-compose build --progress=plain
#   install node_modules in current folder, it is mapped into dev ui container, 
#   so we can modify source files at host and dev container see the changes.
	docker-compose run ui npm install
#   NOTE: prod container will have node_modules inside the image (docker target=prod)
ps:
	docker-compose ps
logs:
	docker-compose logs -f
log: logs

~/gurren:
	@echo "First, create $$HOME/gurren folder, see README.md"
	@exit 2

up: ~/gurren
	test -f $(DEV_CERT) || touch $(DEV_CERT)
	chmod 600 $(DEV_CERT)
	docker-compose up -d --remove-orphans
	$(MAKE) logs
down:
	docker-compose down
restart: down up

pycheck:
	docker-compose run --rm mypy mypy src

up-prod: 
	test -f $(CERT) || touch $(CERT)
	chmod 600 $(CERT)
	$(DC) build
	$(DC) up -d --remove-orphans
down-prod:
	$(DC) down
ps-prod:
	$(DC) ps
